from presenter import basepresenter
from task import userprofiletask

class AdminMessagePresenter(basepresenter.BasePresenter):

    def respondToGet(self):
        # get the subscriber count
        subscribers = self.userprofiletask.getSubscribers()
        subscribercount = subscribers.count()
        self.template_values['subscribercount'] = subscribercount;
        self.template_values['subscribers'] = subscribers

        # set up the page title
        page_title = self.sitetitle + ' - Send Message To Subscribers'
        self.template_values['page_title'] = page_title

        #get the view to draw the page
        self.view.showGetResponse(self.template_values)

    def respondToPost(self):
        # generate and send the emails
        self.userprofiletask.sendSubscriberMessage(self.request.get('title'), self.request.get('message'))
        self.view.showPostResponse(self.template_values)